package chat.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.whu.zj.MyApplication;
import com.whu.zj.R;

import java.util.ArrayList;
import java.util.List;

import model.MessageNotify;

/**
 * 通知界面
 * Created by 凯 on 2015/11/2.
 */
public class NotifyAdapter extends BaseAdapter {


    List<MessageNotify> messageNotifies = new ArrayList<MessageNotify>();

    public void setMessageNotifies(List<MessageNotify> messageNotifies) {
        this.messageNotifies = messageNotifies;
    }

    @Override
    public int getCount() {
        return messageNotifies.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MessageNotify messageNotify = messageNotifies.get(position);
        convertView = View.inflate(MyApplication.share(),R.layout.item_notify,null);

        ImageView imageView = (ImageView) convertView.findViewById(R.id.id_img_avar);
        TextView tv_account = (TextView) convertView.findViewById(R.id.id_tv_account);
        TextView tv_content = (TextView) convertView.findViewById(R.id.id_tv_lastmsg);
        TextView tv_time = (TextView) convertView.findViewById(R.id.id_tv_time);
        TextView tv_unread = (TextView) convertView.findViewById(R.id.id_tv_unread);

        tv_account.setText(messageNotify.getRealName());
        tv_content.setText(messageNotify.getContent());
        tv_time.setText(messageNotify.getTime());
        tv_unread.setText(messageNotify.getUnread());

        if (messageNotify.getUnread().equals("0"))
        {
            tv_unread.setVisibility(View.GONE);
        }

        if (messageNotify.getType().equals("8"))
        {

        }
        else if (messageNotify.getType().equals("5"))
        {
            imageView.setImageResource(R.drawable.group_avar_default);
        }

        return convertView;
    }


}
